﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Molia.NetKernel.Data
{
    public class DataProvider
    {
        public DataProvider()
        {

        }
        public Broadcast CreateBroadCast(string HTML)
        {
            return new Broadcast() { data = Getbytes(HTML) };
        }
        private byte[] Getbytes(byte[] data)
        {
            byte[] buffer = new byte[data.Length + 4];
            byte[] length = BitConverter.GetBytes(data.Length);
            Array.Copy(buffer, length, 4);
            Array.Copy(data, 0, buffer, 4, data.Length);
            return buffer;
        }
        private byte[] Getbytes(string str)
        {
            var data = Encoding.UTF8.GetBytes(str);
            return Getbytes(data);
        }
    }
}
